package cn.gqr.tool;

import cn.gqr.entity.User;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;

public class GetUser {

    public static Object getUser(){
        Object principal =
                SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if(principal==null) return null;
        if(principal instanceof UserDetails){
            return (UserDetails) principal;
        }else {
            return  String.valueOf(principal);
        }
    }

}
